<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/send/deliveryOrder.js"></script>
  </head>
  <body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
	    	<form id="query-form" class="search_form clearfix">
				<dl>
	            	<dt>接单时间：从</dt>
	                <dd>
		                <input name="startAtStr" id="startAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/> 到 
		                <input name="endAtStr" id="endAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/>
	                </dd>
	            </dl>
	            <dl>
					<dt>订单号：</dt>
					<dd>
						<input name="orderNo" id="orderNo" type="text" class="txt" maxlength="64"/>
					</dd>
				</dl>
				<p class="cl"></p>
				<dl>
	                <dt>供应商：</dt>
	                <dd>
	                	<select name="supplierId" id="supplierId" class="txt grid-8">
		                	<option value="">--请选择--</option>
		                	<c:forEach var="supplier" items="${mallSupplierList}">
		                        <option value="${supplier.id}">${supplier.name}</option>
		                	</c:forEach>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>取件状态：</dt>
	                <dd>
	                	<select name="pickupStatus" id="pickupStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">未取件</option>
	                		<option value="2">已取件</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>配送状态：</dt>
	                <dd>
	                	<select name="deliveryStatus" id="deliveryStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">未配送</option>
	                		<option value="2">已配送</option>
	                	</select>
	                </dd>
	            </dl>
	            
	            <p class="search_form_btn">
	            	<input type="button" value="搜索" class="icon_serach" onclick="admin.deliveryOrder.query()" />
	            </p>
	            <dl></dl>
	            <p class="search_form_btn">
	            	<input type="button" value="导出excel" class="icon_serach" onclick="admin.deliveryOrder.export2Excel()" />
	            </p>
	        </form>
	  	</div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" >
				<thead>
					<tr>
						<th data-options="field:'orderNo',width:120,align:'center'">订单号</th>
						<th data-options="field:'orderTitle',width:100,align:'center'">订单名称</th>
						<th data-options="field:'communityName',width:100,align:'center'">社区名称</th>
						<th data-options="field:'strId',width:60,align:'center'">配送单号</th>
						<th data-options="field:'strNewAt',width:100,align:'center'">接单时间</th>
						<th data-options="field:'strPickupStatus',width:60,align:'center'">取件状态</th>
						<th data-options="field:'strPickupAt',width:100,align:'center'">取件时间</th>
						<th data-options="field:'strDeliveryStatus',width:60,align:'center'">配送状态</th>
						<th data-options="field:'strDeliveryAt',width:100,align:'center'">配送时间</th>
						<th data-options="field:'quantityTotal',width:80,align:'center'">商品总数量</th>
						<th data-options="field:'userNick',width:80,align:'center'">买家昵称</th>
						<th data-options="field:'consignee',width:80,align:'center'">联系人</th>
						<th data-options="field:'phone',width:100,align:'center'">联系电话</th>
						<th data-options="field:'address',width:120,align:'center'">收货地址</th>
						<th data-options="field:'supplierName',width:120,align:'center'">供应商</th>
						<th data-options="field:'supplierPhone',width:100,align:'center'">供应商电话</th>
						<th data-options="field:'supplierAddress',width:120,align:'center'">供应商地址</th>
			            <th data-options="field:'id',align:'center',width:100,formatter:formatOperation">操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>
	<form id="export-form" method="post">
		<input name="orderNo" id="export_orderNo" type="hidden"/>
		<input name="supplierId" id="export_supplierId" type="hidden"/>
		<input name="pickupStatus" id="export_pickupStatus" type="hidden"/>
		<input name="deliveryStatus" id="export_deliveryStatus" type="hidden"/>
		<input name="startAtStr" id="export_startAtStr" type="hidden"/>
		<input name="endAtStr" id="export_endAtStr" type="hidden"/>
		<input name="communityId" id="export_communityId" type="hidden"/>
	</form>
  </body>
</html>
<script>
	function formatOperation(value,row,index) {
		var l_html = '';
		l_html += '<a href="javascript:;" class="table_link" onclick="admin.deliveryOrder.detail('+row.id+')">查看</a>';
		return l_html;
	}
	/**
    * EasyUI DataGrid根据字段动态合并单元格
    * param tableID 要合并table的id
    * param colList 要合并的列,用逗号分隔(例如："name,department,office");
    * param mainColIndex 要合并的主列索引
    */
    function mergeCellsByField(tableID, colList, mainColIndex) {
        var ColArray = colList.split(",");
        var tTable = $('#' + tableID);
        var TableRowCnts = tTable.datagrid("getRows").length;
        var tmpA;
        var tmpB;
        var PerTxt = "";
        var CurTxt = "";
        var alertStr = "";
        for (var i = 0; i <= TableRowCnts ; i++) {
            if (i == TableRowCnts) {
                CurTxt = "";
            }
            else {
                CurTxt = tTable.datagrid("getRows")[i][ColArray[mainColIndex]];
            }
            if (PerTxt == CurTxt) {
                tmpA += 1;
            }
            else {
                tmpB += tmpA;
                for (var j = 0; j < ColArray.length; j++) {
                    tTable.datagrid('mergeCells', {
                        index: i - tmpA,
                        field: ColArray[j],
                        rowspan: tmpA,
                        colspan: null
                    });
                }
                tmpA = 1;
            }
            PerTxt = CurTxt;
        }
    }
    function doMergeCellsByField(){
    	mergeCellsByField("datagrid", "orderNo,orderTitle", 0);
    }
    $(document).ready(function() {
    	$('#datagrid').datagrid({  
            url  :'${pageContext.request.contextPath}/send/deliveryOrder/list',  
            onLoadSuccess: doMergeCellsByField  
        })
    });
</script>